package com.oct.ywsc.job;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.core.KafkaTemplate;

/**
 * kafka 客户端操作类
 */
public class CustomerKafkaProducer {
    private static final Logger log = LoggerFactory.getLogger(CustomerKafkaProducer.class);

//    private AdminClient adminClient;
//
//    private KafkaListenerEndpointRegistrar kafkaListenerEndpointRegistrar;

    private KafkaTemplate kafkaTemplate;


    public CustomerKafkaProducer(
                               KafkaTemplate kafkaTemplate
                               ){
        this.kafkaTemplate = kafkaTemplate;

    }

    public void send(String topic, String key, String value) {
        kafkaTemplate.send(topic, key, value);
    }

    public void send(String topic, String value) {
        log.info(String.format("发送消息到kafka topic[%s],msg[%s]",topic,value));
        kafkaTemplate.send(topic, value);
    }


}
